package com.blb.day2;

/**
 * 饿汉式单例模式
 */
public class Singleton1 {

    //2、定义静态对象
    private static Singleton1 instance = new Singleton1();

    //1、私有化构造方法
    private Singleton1(){
        System.out.println("创建了一个对象");
    }

    //3、静态方法返回对象
    public static Singleton1 getInstance(){
        return instance;
    }
}
